<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>window.cpp 示例文件 | Qt Widgets 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-widgets-spinboxes-example.html">Spin Boxes Example</a></td><td >window.cpp 示例文件</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">window.cpp 示例文件</h1>
<span class="subtitle">widgets/spinboxes/window.cpp</span>
<!-- $$$widgets/spinboxes/window.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp">

  <span class="comment">/****************************************************************************
  **
  ** Copyright (C) 2016 The Qt Company Ltd.
  ** Contact: https://www.qt.io/licensing/
  **
  ** This file is part of the examples of the Qt Toolkit.
  **
  ** $QT_BEGIN_LICENSE:BSD$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and The Qt Company. For licensing terms
  ** and conditions see https://www.qt.io/terms-conditions. For further
  ** information use the contact form at https://www.qt.io/contact-us.
  **
  ** BSD License Usage
  ** Alternatively, you may use this file under the terms of the BSD license
  ** as follows:
  **
  ** &quot;Redistribution and use in source and binary forms, with or without
  ** modification, are permitted provided that the following conditions are
  ** met:
  **   * Redistributions of source code must retain the above copyright
  **     notice, this list of conditions and the following disclaimer.
  **   * Redistributions in binary form must reproduce the above copyright
  **     notice, this list of conditions and the following disclaimer in
  **     the documentation and/or other materials provided with the
  **     distribution.
  **   * Neither the name of The Qt Company Ltd nor the names of its
  **     contributors may be used to endorse or promote products derived
  **     from this software without specific prior written permission.
  **
  **
  ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  ** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/</span>

  <span class="preprocessor">#include &lt;QtWidgets&gt;</span>

  <span class="preprocessor">#include &quot;window.h&quot;</span>

  Window<span class="operator">::</span>Window()
  {
      createSpinBoxes();
      createDateTimeEdits();
      createDoubleSpinBoxes();

      <span class="type"><a href="qhboxlayout.html">QHBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qhboxlayout.html">QHBoxLayout</a></span>;
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(spinBoxesGroup);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(editsGroup);
      layout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(doubleSpinBoxesGroup);
      setLayout(layout);

      setWindowTitle(tr(<span class="string">&quot;Spin Boxes&quot;</span>));
  }

  <span class="type">void</span> Window<span class="operator">::</span>createSpinBoxes()
  {
      spinBoxesGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;Spinboxes&quot;</span>));

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>integerLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a value between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="operator">-</span><span class="number">20</span>)<span class="operator">.</span>arg(<span class="number">20</span>));
      <span class="type"><a href="qspinbox.html">QSpinBox</a></span> <span class="operator">*</span>integerSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      integerSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="operator">-</span><span class="number">20</span><span class="operator">,</span> <span class="number">20</span>);
      integerSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">1</span>);
      integerSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">0</span>);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>zoomLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a zoom value between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="number">0</span>)<span class="operator">.</span>arg(<span class="number">1000</span>));
      <span class="type"><a href="qspinbox.html">QSpinBox</a></span> <span class="operator">*</span>zoomSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      zoomSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">1000</span>);
      zoomSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">10</span>);
      zoomSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSuffix(<span class="string">&quot;%&quot;</span>);
      zoomSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSpecialValueText(tr(<span class="string">&quot;Automatic&quot;</span>));
      zoomSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">100</span>);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>priceLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a price between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="number">0</span>)<span class="operator">.</span>arg(<span class="number">999</span>));
      <span class="type"><a href="qspinbox.html">QSpinBox</a></span> <span class="operator">*</span>priceSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">999</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">1</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setPrefix(<span class="string">&quot;$&quot;</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">99</span>);

      groupSeparatorSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      groupSeparatorSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="operator">-</span><span class="number">99999999</span><span class="operator">,</span> <span class="number">99999999</span>);
      groupSeparatorSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">1000</span>);
      groupSeparatorSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setGroupSeparatorShown(<span class="keyword">true</span>);
      <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>groupSeparatorChkBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>;
      groupSeparatorChkBox<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Show group separator&quot;</span>));
      groupSeparatorChkBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);
      connect(groupSeparatorChkBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qcheckbox.html">QCheckBox</a></span><span class="operator">::</span>toggled<span class="operator">,</span> groupSeparatorSpinBox<span class="operator">,</span>
              <span class="operator">&amp;</span><span class="type"><a href="qspinbox.html">QSpinBox</a></span><span class="operator">::</span>setGroupSeparatorShown);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>hexLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a value between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="char">'-'</span> <span class="operator">+</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span><span class="operator">::</span>number(<span class="number">31</span><span class="operator">,</span> <span class="number">16</span>))<span class="operator">.</span>arg(<span class="type"><a href="../qtcore/qstring.html">QString</a></span><span class="operator">::</span>number(<span class="number">31</span><span class="operator">,</span> <span class="number">16</span>)));
      <span class="type"><a href="qspinbox.html">QSpinBox</a></span> <span class="operator">*</span>hexSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      hexSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="operator">-</span><span class="number">31</span><span class="operator">,</span> <span class="number">31</span>);
      hexSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">1</span>);
      hexSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">0</span>);
      hexSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setDisplayIntegerBase(<span class="number">16</span>);

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>spinBoxLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(integerLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(integerSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(zoomLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(zoomSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(priceLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(priceSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(hexLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(hexSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupSeparatorChkBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupSeparatorSpinBox);
      spinBoxesGroup<span class="operator">-</span><span class="operator">&gt;</span>setLayout(spinBoxLayout);
  }

  <span class="type">void</span> Window<span class="operator">::</span>createDateTimeEdits()
  {
      editsGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;Date and time spin boxes&quot;</span>));

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>dateLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      <span class="type"><a href="qdateedit.html">QDateEdit</a></span> <span class="operator">*</span>dateEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdateedit.html">QDateEdit</a></span>(<span class="type"><a href="../qtcore/qdate.html">QDate</a></span><span class="operator">::</span>currentDate());
      dateEdit<span class="operator">-</span><span class="operator">&gt;</span>setDateRange(<span class="type"><a href="../qtcore/qdate.html">QDate</a></span>(<span class="number">2005</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">1</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qdate.html">QDate</a></span>(<span class="number">2010</span><span class="operator">,</span> <span class="number">12</span><span class="operator">,</span> <span class="number">31</span>));
      dateLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Appointment date (between %0 and %1):&quot;</span>)
                         <span class="operator">.</span>arg(dateEdit<span class="operator">-</span><span class="operator">&gt;</span>minimumDate()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate))
                         <span class="operator">.</span>arg(dateEdit<span class="operator">-</span><span class="operator">&gt;</span>maximumDate()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate)));

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>timeLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      <span class="type"><a href="qtimeedit.html">QTimeEdit</a></span> <span class="operator">*</span>timeEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtimeedit.html">QTimeEdit</a></span>(<span class="type"><a href="../qtcore/qtime.html">QTime</a></span><span class="operator">::</span>currentTime());
      timeEdit<span class="operator">-</span><span class="operator">&gt;</span>setTimeRange(<span class="type"><a href="../qtcore/qtime.html">QTime</a></span>(<span class="number">9</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qtime.html">QTime</a></span>(<span class="number">16</span><span class="operator">,</span> <span class="number">30</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>));
      timeLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Appointment time (between %0 and %1):&quot;</span>)
                         <span class="operator">.</span>arg(timeEdit<span class="operator">-</span><span class="operator">&gt;</span>minimumTime()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate))
                         <span class="operator">.</span>arg(timeEdit<span class="operator">-</span><span class="operator">&gt;</span>maximumTime()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate)));

      meetingLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>;
      meetingEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdatetimeedit.html">QDateTimeEdit</a></span>(<span class="type"><a href="../qtcore/qdatetime.html">QDateTime</a></span><span class="operator">::</span>currentDateTime());

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>formatLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Format string for the meeting date &quot;</span>
                                          <span class="string">&quot;and time:&quot;</span>));
      <span class="type"><a href="qcombobox.html">QComboBox</a></span> <span class="operator">*</span>formatComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
      formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;yyyy-MM-dd hh:mm:ss (zzz 'ms')&quot;</span>);
      formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;hh:mm:ss MM/dd/yyyy&quot;</span>);
      formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;hh:mm:ss dd/MM/yyyy&quot;</span>);
      formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;hh:mm:ss&quot;</span>);
      formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>addItem(<span class="string">&quot;hh:mm ap&quot;</span>);

      connect(formatComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type"><a href="../qtcore/qstring.html">QString</a></span>))<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> SLOT(setFormatString(<span class="type"><a href="../qtcore/qstring.html">QString</a></span>)));

      setFormatString(formatComboBox<span class="operator">-</span><span class="operator">&gt;</span>currentText());

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>editsLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(dateLabel);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(dateEdit);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(timeLabel);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(timeEdit);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(meetingLabel);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(meetingEdit);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(formatLabel);
      editsLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(formatComboBox);
      editsGroup<span class="operator">-</span><span class="operator">&gt;</span>setLayout(editsLayout);
  }

  <span class="type">void</span> Window<span class="operator">::</span>setFormatString(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>formatString)
  {
      meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>setDisplayFormat(formatString);
      <span class="keyword">if</span> (meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>displayedSections() <span class="operator">&amp;</span> <span class="type"><a href="qdatetimeedit.html">QDateTimeEdit</a></span><span class="operator">::</span>DateSections_Mask) {
          meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>setDateRange(<span class="type"><a href="../qtcore/qdate.html">QDate</a></span>(<span class="number">2004</span><span class="operator">,</span> <span class="number">11</span><span class="operator">,</span> <span class="number">1</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qdate.html">QDate</a></span>(<span class="number">2005</span><span class="operator">,</span> <span class="number">11</span><span class="operator">,</span> <span class="number">30</span>));
          meetingLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Meeting date (between %0 and %1):&quot;</span>)
              <span class="operator">.</span>arg(meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>minimumDate()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate))
              <span class="operator">.</span>arg(meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>maximumDate()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate)));
      } <span class="keyword">else</span> {
          meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>setTimeRange(<span class="type"><a href="../qtcore/qtime.html">QTime</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">7</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">0</span>)<span class="operator">,</span> <span class="type"><a href="../qtcore/qtime.html">QTime</a></span>(<span class="number">21</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>));
          meetingLabel<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Meeting time (between %0 and %1):&quot;</span>)
              <span class="operator">.</span>arg(meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>minimumTime()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate))
              <span class="operator">.</span>arg(meetingEdit<span class="operator">-</span><span class="operator">&gt;</span>maximumTime()<span class="operator">.</span>toString(<span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">::</span>ISODate)));
      }
  }

  <span class="type">void</span> Window<span class="operator">::</span>createDoubleSpinBoxes()
  {
      doubleSpinBoxesGroup <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qgroupbox.html">QGroupBox</a></span>(tr(<span class="string">&quot;Double precision spinboxes&quot;</span>));

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>precisionLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Number of decimal places &quot;</span>
                                             <span class="string">&quot;to show:&quot;</span>));
      <span class="type"><a href="qspinbox.html">QSpinBox</a></span> <span class="operator">*</span>precisionSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qspinbox.html">QSpinBox</a></span>;
      precisionSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0</span><span class="operator">,</span> <span class="number">100</span>);
      precisionSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">2</span>);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>doubleLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a value between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="operator">-</span><span class="number">20</span>)<span class="operator">.</span>arg(<span class="number">20</span>));
      doubleSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdoublespinbox.html">QDoubleSpinBox</a></span>;
      doubleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="operator">-</span><span class="number">20.0</span><span class="operator">,</span> <span class="number">20.0</span>);
      doubleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">1.0</span>);
      doubleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">0.0</span>);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>scaleLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a scale factor between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="number">0</span>)<span class="operator">.</span>arg(<span class="number">1000.0</span>));
      scaleSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdoublespinbox.html">QDoubleSpinBox</a></span>;
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0.0</span><span class="operator">,</span> <span class="number">1000.0</span>);
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">10.0</span>);
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSuffix(<span class="string">&quot;%&quot;</span>);
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSpecialValueText(tr(<span class="string">&quot;No scaling&quot;</span>));
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">100.0</span>);

      <span class="type"><a href="qlabel.html">QLabel</a></span> <span class="operator">*</span>priceLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Enter a price between &quot;</span>
          <span class="string">&quot;%1 and %2:&quot;</span>)<span class="operator">.</span>arg(<span class="number">0</span>)<span class="operator">.</span>arg(<span class="number">1000</span>));
      priceSpinBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdoublespinbox.html">QDoubleSpinBox</a></span>;
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="number">0.0</span><span class="operator">,</span> <span class="number">1000.0</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setSingleStep(<span class="number">1.0</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setPrefix(<span class="string">&quot;$&quot;</span>);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">99.99</span>);

      connect(precisionSpinBox<span class="operator">,</span> SIGNAL(valueChanged(<span class="type">int</span>))<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> SLOT(changePrecision(<span class="type">int</span>)));

      groupSeparatorSpinBox_d <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdoublespinbox.html">QDoubleSpinBox</a></span>;
      groupSeparatorSpinBox_d<span class="operator">-</span><span class="operator">&gt;</span>setRange(<span class="operator">-</span><span class="number">99999999</span><span class="operator">,</span> <span class="number">99999999</span>);
      groupSeparatorSpinBox_d<span class="operator">-</span><span class="operator">&gt;</span>setDecimals(<span class="number">2</span>);
      groupSeparatorSpinBox_d<span class="operator">-</span><span class="operator">&gt;</span>setValue(<span class="number">1000.00</span>);
      groupSeparatorSpinBox_d<span class="operator">-</span><span class="operator">&gt;</span>setGroupSeparatorShown(<span class="keyword">true</span>);
      <span class="type"><a href="qcheckbox.html">QCheckBox</a></span> <span class="operator">*</span>groupSeparatorChkBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcheckbox.html">QCheckBox</a></span>;
      groupSeparatorChkBox<span class="operator">-</span><span class="operator">&gt;</span>setText(tr(<span class="string">&quot;Show group separator&quot;</span>));
      groupSeparatorChkBox<span class="operator">-</span><span class="operator">&gt;</span>setChecked(<span class="keyword">true</span>);
      connect(groupSeparatorChkBox<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qcheckbox.html">QCheckBox</a></span><span class="operator">::</span>toggled<span class="operator">,</span> groupSeparatorSpinBox_d<span class="operator">,</span>
              <span class="operator">&amp;</span><span class="type"><a href="qdoublespinbox.html">QDoubleSpinBox</a></span><span class="operator">::</span>setGroupSeparatorShown);

      <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>spinBoxLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(precisionLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(precisionSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(doubleLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(doubleSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(scaleLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(scaleSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(priceLabel);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(priceSpinBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupSeparatorChkBox);
      spinBoxLayout<span class="operator">-</span><span class="operator">&gt;</span>addWidget(groupSeparatorSpinBox_d);
      doubleSpinBoxesGroup<span class="operator">-</span><span class="operator">&gt;</span>setLayout(spinBoxLayout);
  }

  <span class="type">void</span> Window<span class="operator">::</span>changePrecision(<span class="type">int</span> decimals)
  {
      doubleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setDecimals(decimals);
      scaleSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setDecimals(decimals);
      priceSpinBox<span class="operator">-</span><span class="operator">&gt;</span>setDecimals(decimals);
  }

</pre>
</div>
<!-- @@@widgets/spinboxes/window.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
